package cn.jetpiece.cloud.joss.app.core.utils;

import cn.jetpiece.cloud.joss.app.config.properties.OssProperties;
import cn.jetpiece.cloud.joss.app.core.constant.OssConstants;

public class ObjectUrlUtils {

    /**
     * 获取对象地址
     *
     * @param bucketName 桶名
     * @param objectName 对象名
     * @return 对象地址
     */
    public static String getObjectUrl(String bucketName, String objectName) {
        StringBuilder builder = new StringBuilder();
        builder.append(OssProperties.getInstance().getBasePreviewUrl());
        builder.append("/get-object/");
        builder.append(bucketName);
        if (objectName.startsWith(OssConstants.PATH_SEPARATE)) {
            builder.append(objectName);
            return builder.toString();
        }
        builder.append(OssConstants.PATH_SEPARATE);
        builder.append(objectName);
        return builder.toString();
    }
}
